﻿/**
  KCAKCAK   CAKCAKC   AK      CA
 AK        KC     CA  AK    AK
CA         KC     CA  AK  KC
CA         KCAKCAKCA  AKCA
CA         KC     CA  AK  KC
 AK        KC     CA  AK    AK
  KCAKCAK  KC     CA  AK      CA

_________________________________________________________________
 China ataca Kamchatka - copyright 2007(c) Ruben Sainz de la Maza
 
	@class: 	Player
	@vertion: 	0.1
	@date:		28/11/07
				
	@language: 	ActionScript 3.0
	@author:	Ruben Sainz de la Maza
	@usage: 
		var objPlayer:Player = new Player("Ruben", "Negro");
		_objPlayers[pName] = objPlayer;				
		trace(_objPlayers.Ruben.pName);
		trace(_objPlayers.Ruben.pColor); 
		
**/

package com.conelmate.cak.players
{
	
	import com.conelmate.util.Trace;
	
	
	public class Player extends Trace implements IPlayer
	{
		
		private var _objPSM			:PlayerStateMachine;	//ref a la maquina de estados
		
		private var	_isFreeze		:Boolean = false;		//true:congela eventos, false:reactiva eventos
		
		private	var	_strName		:String;				//nombre del jugador
		private	var	_strColor		:String;				//color. Posiblidaddes: AZUL NEGRO ROJO BLANCO VERDE AMARILLO
		
		private	var	_intObjective	:Number;				//id del objetivo a cumplir
		private	var	_intForces		:Number;				//cantidad de ejercitos
		
		private	var	_objCountries	:Object;				//paises
		private	var	_objCards		:Object;				//tarjetas del jugador, acumuladas en cada ronda
		


//_________________________________________________________________________________ Constructor
		public function Player(pColor:String = null, pName:String = null)
		{
			_isTrace = false;
			mTrace("#Player# constructor");
			
			if(pColor	!= null) _strColor = pColor;
			if(pName 	!= null) _strName  = pName;
						
			_objPSM = new PlayerStateMachine();
			_objPSM.init();
		
			//Setear el estado del jugador: ATTACK DEFEND PUT REORGANIZE STANDBY(default)
		//	_objPSM.state = PlayerStateMachine.ATTACK;
		//	_objPSM.state = PlayerStateMachine.DEFEND;
		//	_objPSM.state = PlayerStateMachine.PUT;
		//	_objPSM.state = PlayerStateMachine.REORGANIZE;
		//	_objPSM.state = PlayerStateMachine.STANDBY;
		}
		

//_________________________________________________________________________________ Public Methods

		/**
		 * Inicializa la clase
		 */
		public function init():void
		{
			mTrace("#Player " + _objPSM.state + "# init");
		}
		

		/**
		 * Destruye las instancias
		 */
		public function destroy():void
		{
			mTrace("#Player " + _objPSM.state + "# destroy");
		}
		
		
		/**
		 * Congela / descongela los eventos de la clase
		 * @param   freeze 
		 */		
		public function freeze(freeze:Boolean):void
		{
			mTrace("#Player " + _objPSM.state + "# freeze");
			_isFreeze = freeze;
		}
		

//_________________________________________________________________________________ Private Methods




//_________________________________________________________________________________ GETTERS

		public function get pName()			:String	{ return _strName; }
		public function get pColor()		:String	{ return _strColor; }
		public function get pObjective()	:Number	{ return _intObjective; }
		public function get pForces()		:Number	{ return _intForces; }

//_________________________________________________________________________________ SETTERS	

		public function set pName			(p:String)	{ _strName = p; }
		public function set pColor			(p:String)	{ _strColor = p; }
		public function set pObjective		(p:Number)	{ _intObjective = p; }
		public function set pForces			(p:Number)	{ _intForces = p; }

	}
}